package Application.FirstApplication.view.scene
{
	import Application.FirstApplication.def.Def;
	import Application.FirstApplication.def.Manager;
	import Application.FirstApplication.view.ViewBaseMed;
	import Application.FirstApplication.view.ui.Login;
	
	import def.XG;
	
	import fl.controls.ProgressBar;
	import fl.controls.ProgressBarDirection;
	import fl.controls.ProgressBarMode;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.display.Stage;
	
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class PreLoadingMed extends ViewBaseMed
	{
		public var m_preloadingBar : ProgressBar;
		
		public var m_login : Login;
		
		public function PreLoadingMed()
		{
			super(Def.PreloadingScene);
			
			m_login = new Login;
		}
		
		override public function onRegister():void
		{
			trace(super.viewComponent,viewComponent);
			m_preloadingBar = viewComponent["Bar_PreLoading"];
			m_preloadingBar.setProgress(0,100);
			m_preloadingBar.mode =ProgressBarMode.MANUAL
			m_preloadingBar.value = 0;
		}
		
		override public function listNotificationInterests():Array
		{
			return [Def.LOADSOURCE_PROGRESS,
			         Def.LOADSOURCE_PROGRESS];
		}
		
		override public function handleNotification(notification:INotification):void
		{
			switch(notification.getName())
			{
				case Def.LOADSOURCE_PROGRESS:
					var loadByteInfo : Object = notification.getBody();
					
					m_preloadingBar.value = loadByteInfo["bytesLoaded"]/loadByteInfo["bytesTotal"] * 100;
					
					break;
				default :
					break;
			}
		}
		
	}
}